﻿using Sustainalytics.LongRunningTaskManager.Interface;

namespace Sustainalytics.LongRunningTaskManager.Service
{
    using System;

    /// <summary>
    /// Exceptions extensions.
    /// </summary>
    public static class ExceptionsExtensions
    {
        public static object GetHttpResponseMessageDto(this Exception ex)
        {
            if (ex is LongRunningTaskManagerStoppingException)
            {
                return new { Code = (int)LongRunningTaskManagerErrorCodes.MaxTasksPerUserReached };
            }

            if (ex is LongRunningMaxTasksPerUserReachedException)
            {
                return new { Code = (int)LongRunningTaskManagerErrorCodes.MaxTasksPerUserReached };  
            }

            return null;
        }
    }
}
